<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}yy校园-后台首页{% endblock %}</title>
    <link rel="stylesheet" href="/static/UI/layui-v2.9.6/layui/css/layui.css">
    {% block css %}{% endblock %}
</head>

<body>
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo layui-hide-xs layui-bg-black">YY校园后台</div>
            <!-- 头部区域（可配合layui 已有的水平导航） -->
            <ul class="layui-nav layui-layout-left">
                <!-- 移动端显示 -->
                <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                    <i class="layui-icon layui-icon-spread-left"></i>
                </li>
                <!-- <li class="layui-nav-item layui-hide-xs"><a href="javascript:;">nav 3</a></li> -->
                <!-- <li class="layui-nav-item">
              <a href="javascript:;">nav groups</a>
              <dl class="layui-nav-child">
                <dd><a href="javascript:;">menu 11</a></dd>
                <dd><a href="javascript:;">menu 22</a></dd>
                <dd><a href="javascript:;">menu 33</a></dd>
              </dl>
            </li> -->
            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                    <a href="javascript:;">
                        <!-- <img src="https://unpkg.com/outeres@0.0.10/img/layui/icon-v2.png" class="layui-nav-img"> -->
                        tester
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;">Your Profile</a></dd>
                        <dd><a href="javascript:;">Settings</a></dd>
                        <dd><a href="javascript:;">Sign out</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                    <a href="javascript:;">
                        <i class="layui-icon layui-icon-more-vertical"></i>
                    </a>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- layui-nav-itemed 展开 layui-this -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">

                    <li class="layui-nav-item {% if request.path == '/index/' %}layui-this{% endif %} "><a
                            href="/index/">首页</a></li>
                    <li class="layui-nav-item   {% if 'store'  in request.path %}layui-nav-itemed{% endif %}">
                        <a class="" href="javascript:;">商店</a>
                        <dl class="layui-nav-child">
                            <dd class=" {% if request.path == '/store/create/' %}layui-this{% endif %} "><a
                                    href="/store/create/">添加商店</a></dd>
                        </dl>

                        <dl class="layui-nav-child">
                            <dd class=" {% if request.path == '/store/goods/create/nav/' %}layui-this{% endif %} "><a
                                    href="/store/goods/create/nav/">创建商品导航</a></dd>
                        </dl>

                        <dl class="layui-nav-child">
                            <dd class=" {% if request.path == '/store/create/goods/' %}layui-this{% endif %} "><a
                                    href="/store/create/goods/">新增商品</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>
        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div style="padding: 15px;">
                {% block centent %}{% endblock %}
            </div>
        </div>

    </div>
</body>
<script src="/static/PublicJs/axios.js"></script>

<script src="/static/UI/layui-v2.9.6/layui/layui.js"></script>
<script src="/static/PublicJs/YYJS.js"></script>
<script>
    var form = layui.form;
    var layer = layui.layer;
    var upload = layui.upload;
    var element = layui.element;
    var $ = layui.$;
    // 上传图片
    function yy_upimg(res,type) {

        let index1 = layer.open({
            type: 1,
            title: "添加成功, 请上传封面",
            content: `
            <div style="padding:100px;">
                <button type="button" class="layui-btn" id="ID-upload-demo-btn">
            <i class="layui-icon layui-icon-upload"></i> 单图片上传
            </button>
                <div style="width: 132px;">
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="ID-upload-demo-img" style="width: 100%; height: 92px;">
                        <div id="ID-upload-demo-text"></div>
                    </div>
                    <div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-demo">
                        <div class="layui-progress-bar" lay-percent=""></div>
                    </div>
                </div>
            </div>
            `,
        });
        let uploadInst = upload.render({
            elem: '#ID-upload-demo-btn',
            url: DOMAIN + 'api/upfile/store/images/', // 实际使用时改成您自己的上传接口即可。
            field: "image_url",
            data: {
                "title": res.data.name,
                "image_type": type,
                "image_id": res.data.id
            },
            before: function (obj) {
                // 预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#ID-upload-demo-img').attr('src', result); // 图片链接（base64）
                });
                element.progress('filter-demo', '0%'); // 进度条复位
                layer.msg('上传中', { icon: 16, time: 0 });
            },
            done: function (res) {
                // 若上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                } else {
                    layer.closeAll('page');
                }

                $('#ID-upload-demo-text').html(''); // 置空上传失败的状态
            },
            error: function () {
                // 演示失败状态，并实现重传
                var demoText = $('#ID-upload-demo-text');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            },
            // 进度条
            progress: function (n, elem, e) {
                element.progress('filter-demo', n + '%'); // 可配合 layui 进度条元素使用
                if (n == 100) {
                    layer.msg('上传完毕', { icon: 1 });
                }
            }
        });
    }
</script>
{% block js %}{% endblock %}

</html>